package com.ctshk.rpc.localfun.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.localfun.entity.LocalFunProductSaleStrategyVaildDate;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Collection;

/**
 * @Description
 * @Author wansi <gaylen15527491065@yeah.net>
 * @Date 2021/3/24
 */
public interface LocalFunProductSaleStrategyVaildDateMapper extends BaseMapper<LocalFunProductSaleStrategyVaildDate> {

    /**
     * 批量插入
     *
     * @param entityList 实体列表
     * @return 影响行数
     */
    Integer insertBatchSomeColumn(Collection<LocalFunProductSaleStrategyVaildDate> entityList);

    /**
     * 清空有效期
     * @param
     * @param
     */
    @Update("UPDATE t_local_fun_product_sale_strategy_vaild_date \n" +
            "SET is_deleted = 1,modified_id = #{modified_id}\n" +
            "WHERE product_id = #{product_id}")
    Integer clearByProductId(@Param("product_id") Long productId, @Param("modified_id")Long userId);

    @Select("<script>"+"select min(time_begin) timeBegin ,max(time_end) timeEnd from t_local_fun_product_sale_strategy_vaild_date where product_id=#{id}" + "</script>")
    LocalFunProductSaleStrategyVaildDate selectValidteTime(Long id);
}
